﻿using AttendanceSysytem.Database.BusinessLogic;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AttendanceSysytem.Controls
{
    public partial class AttendanceConfigPage : BaseControl
    {
        public AttendanceConfigPage()
        {
            InitializeComponent();
            if(!DesignMode  )
                LoadConfig();
        }

        Config_Logic config_Logic = new Config_Logic();

        private void LoadConfig()
        {
           var item = config_Logic.Queryable().Where(a => a.Configkey == "system.overtime.offset").Single();
            txtOverTimeOffset.Value = item.Value.ObjToInt();
        }


        private void btnSave_Click(object sender, EventArgs e)
        {
            var item = config_Logic.Queryable().Where(a => a.Configkey == "system.overtime.offset").Single();
            item.Value = txtOverTimeOffset.Text;
            config_Logic.UpdateSync(item);
            MessageBoxShow("保存成功！");
        }
    }
}
